﻿<!DOCTYPE html>
<html lang="zh-CN" style="background:#f2f2f2;">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" id="viewport" name="viewport">
	<title>上海新兰德</title>
	<!-- <link href="../css/style.css" rel="stylesheet" type="text/css"> -->
	<link href="../css/wxpay.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="../js/jquery-2.1.0.min.js"></script>
	<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>  
	<script type="text/javascript">
	
	var appId,timeStamp,nonceStr,packages,signType,paySign,codeId;
	$(document).ready(function(){
		codeId = location.search;
		//alert(codeId);
		codeId = codeId.substring(codeId.indexOf("=")+1, codeId.length);
		//alert(codeId);
		$(".Pay_btn").click(function(){ 
			//alert($(".number").val());
			$.post("http://test2.mytv365.com/Arena_App/rechanger/create",{"commodityid":"001","commodityprice":$(".number").val(),"commoditynumber":"1","commodityname":"充值","commoditydescribe":"二维码充值","commoditytype":"充值","ip":returnCitySN["cip"],"userTokenId":"10191169"},function(data){
				//alert(data);
				if(data.resultData!=null){
				//alert(data.resultData);
					$.post("http://test2.mytv365.com/Arena_App/rechanger/jsapiOrderInformationw",{"orderNumber":data.resultData,"codeId":codeId},function(data){
						//alert(data);
						//alert(data.resultData);
						//alert(data.resultData.appid);
						if (data!=null) {
							appId=data.resultData.appid;
							timeStamp=data.resultData.timestamp;
							nonceStr=data.resultData.noncestr;
							packages=data.resultData.packages;
							signType=data.resultData.signtype;
							paySign=data.resultData.paySign;
							if (typeof WeixinJSBridge == "undefined"){
								   if(document.addEventListener ){
									   document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
								   }else if (document.attachEvent){
									   document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
									   document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
								   }
								}else{
								   onBridgeReady();
								}
							//onBridgeReady(appId,timeStamp,nonceStr,packages,signType,paySign);
							//alert(appId+"		"+timeStamp+"		"+nonceStr+"		"+packages+"		"+signType+"		"+paySign);
						} else {
							alert("支付失败");
						}
					});
				}else{
					alert("创建失败");
				}
			});
			
		});
	});
	
	
//	function onBridgeReady(appId,timeStamp,nonceStr,packages,signType,paySign){
	function onBridgeReady(){
		//alert(appId+"		"+timeStamp+"		"+nonceStr+"		"+packages+"		"+signType+"		"+paySign);
		   WeixinJSBridge.invoke(
			   'getBrandWCPayRequest', {
				   "appId":appId, //公众号名称，由商户传入	 
				   "timeStamp":timeStamp, //时间戳，自1970年以来的秒数	 
				   "nonceStr":nonceStr, //随机串	 
				   "package":packages,	 
				   "signType":signType, //微信签名方式：	 
				   "paySign":paySign //微信签名 
			   },
			   function(res){
				   //alert(res.err_msg);
			   //WeixinJSBridge.log(res.err_msg);
				   if(res.err_msg == "get_brand_wcpay_request：ok" ) {
					   alert("支付成功");
					   }	 // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回	ok，但并不保证它绝对可靠。 
				   }
			   }
		   ); 
		}
	/* if (typeof WeixinJSBridge == "undefined"){
	   if(document.addEventListener ){
		   document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
	   }else if (document.attachEvent){
		   document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
		   document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
	   }
	}else{
	   onBridgeReady();
	}  */
	
	</script>
	
	
   <!--  <script type="text/javascript">  
	document.write(returnCitySN["cip"]+','+returnCitySN["cname"]);
	document.write(location.search);
   // alert(returnCitySN["cip"]+','+returnCitySN["cname"]);
	</script> -->

</head>
<body>
<div id="Pay">
	<div class="Pay">
		<div class="Pay_top">
			<div class="Pay_tit">请输入金额</div>
			<div class="Pay_Price">
				<!--<img src="images/money2.png"/>-->
				<input type="number" value="0.01" class="number"/>
			</div>
		</div>
		<div class="" style="width: 100%;height: 1.5em;background: #f2f2f2;"></div>
		<p class="Pay_p_low">支付方式</p>
		<div class="Pay_low">
			<ul>
				<li>
					<img src="../images/wx.png"/>
					<p>微信支付</p>
					<div class="btn_radio"></div>
					<div class="clear"></div>
				</li>
				<!--<li>-->
					<!--<img src="images/zfb.png"/>-->
					<!--<p>支付宝支付</p>-->
					<!--<div class="btn_radio"></div>-->
					<!--<div class="clear"></div>-->
				<!--</li>-->
			</ul>
		</div>
		<div class="Pay_btn">确认支付</div>
	</div>
</div>
</body>
</html>